﻿@model Model.AppUserList
@{
    ViewBag.Title = "DCWarehouse";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            InitGrid();

        });

        HandleDom.ClassTriggerClick("icon-add", function () {
            $('#hiddenWAREHOUSEID').val();
            HandleDialog.OpenDialogByAdd('dlg', '添加前置仓库信息', function () {
                HandleData.ClearForm('location');
                $('#stxtWarehouseCode').attr("readonly", false);
                $('#province').combobox('setValue', '上海');
                $('#city').combobox('setValue', '上海');
                $('#district').combobox('setValue', '青浦');
                $('#sstatus').combobox('setValue', '1');
            });
        });

        HandleDom.ClassTriggerClick("icon-edit", function () {
            var row = HandleData.GetDataGridSelected("dg");
            edit(row);
        });

        HandleDom.ClassTriggerClick("icon-reload", function () {
            InitGrid();
        });

        //编辑
        function edit(row) {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialog(row, 'dlg', '编辑前置仓信息', function () {
                $('#hiddenWAREHOUSEID').val(row.WAREHOUSEID);
                $('#stxtWarehouseCode').val(row.WAREHOUSECODE);
                $('#stxtWarehouseName').val(row.WAREHOUSENAME);
                HandleData.SetValueComboBox('province', row.WAREHOUSEPROVINCE);
                HandleData.SetValueComboBox('city', row.WAREHOUSECITY);
                HandleData.SetValueComboBox('district', row.WAREHOUSEDISTRICT);
                $('#txtADDRESS').val(row.WAREHOUSEADDRESS);
                HandleData.SetValueComboBox('sstatus', row.STATUS);
                $('#stxtWarehouseCode').attr("readonly", true);
            });
        }

        function saveData(isClose) {
            HandleRequest.submitForm('location', '@Url.Action("SaveData", "DCWarehouse")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('dlg');
                } else {
                    layer.msg(data.msg, 1);
                }

            });
        }

        function InitGrid() {
            var txtWarehouseCode = $('#txtWarehouseCode').val();
            var txtStatus = $('#status').combobox('getValue');


            queryParams = {
                warehouseCode: txtWarehouseCode,
                status: txtStatus
            }
            HandleData.InitDataGrid('dg', '/DCWarehouse/InitJsonResult', 'toolbar', queryParams, 'WAREHOUSEID', true, function (data) { },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }
    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>仓库编号:
                    </td>
                    <td>
                        <input id="txtWarehouseCode" name="txtWarehouseCode" style="width: 154px" />
                    </td>
                    <td>状态:
                    </td>
                    <td>
                        <select id="status" class="easyui-combobox" name="status" style="width: 154px;">
                            <option value="">--全部--</option>
                            <option value="0">失效</option>
                            <option value="1">生效</option>
                        </select>
                    </td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid()">查询</a>
                    </td>
                </tr>


            </table>
        </form>
    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="前置仓信息" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'WAREHOUSECODE',width:50">仓库编码</th>
                    <th data-options="field:'WAREHOUSENAME',width:50">仓库名称</th>
                    <th data-options="field:'WAREHOUSEPROVINCE',width:50">省份</th>
                    <th data-options="field:'WAREHOUSECITY',width:50">城市</th>
                    <th data-options="field:'WAREHOUSEDISTRICT',width:50">区</th>
                    <th data-options="field:'WAREHOUSEADDRESS',width:130">地址</th>
                    <th data-options="field:'STATUS',width:30,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatValid(value);}">状态</th>
                    <th data-options="field:'OPRNO',width:50">创建人</th>
                    <th data-options="field:'CREATEDATE',width:100,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatDate(value);}">创建时间</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 620px; height: 250px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location" method="post">
            <table>
                <tr>
                    <td>仓库编码:
                    </td>
                    <td>
                        <input id="hiddenWAREHOUSEID" name="hiddenWAREHOUSEID" type="hidden" />
                        <input id="hiddenWAREHOUSECODE" name="hiddenWAREHOUSECODE" type="hidden" />
                        <input id="stxtWarehouseCode" name="stxtWarehouseCode" maxlength="20" style="width: 154px" class="easyui-validatebox" data-options="required:true" />
                    </td>
                    <td>仓库名称:
                    </td>
                    <td>
                        <input id="stxtWarehouseName" name="stxtWarehouseName" maxlength="20" style="width: 154px" class="easyui-validatebox" data-options="required:true" />
                    </td>
                </tr>
                <tr>
                    <td>省份:
                    </td>
                    <td>
                        <select id="province" class="easyui-combobox" name="province" style="width: 154px;">
                            <option value="上海">上海</option>
                        </select>
                    </td>
                    <td>城市:
                    </td>
                    <td>
                        <select id="city" class="easyui-combobox" name="city" style="width: 154px;">
                            <option value="上海">上海</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>区:
                    </td>
                    <td>
                        <select id="district" class="easyui-combobox" name="district" style="width: 154px;">
                            <option value="青浦">青浦</option>
                            <option value="杨浦">杨浦</option>
                            <option value="浦东">浦东</option>
                            <option value="长宁">长宁</option>
                            <option value="嘉定">嘉定</option>
                            <option value="普陀">普陀</option>
                            <option value="虹口">虹口</option>
                            <option value="闵行">闵行</option>
                            <option value="徐汇">徐汇</option>
                        </select>
                    </td>
                    <td>状态:
                    </td>
                    <td>
                        <select id="sstatus" class="easyui-combobox" name="sstatus" style="width: 154px;">
                            <option value="0">失效</option>
                            <option value="1">生效</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>地址:
                    </td>
                    <td colspan="2">
                        <input id="txtADDRESS" name="txtADDRESS" style="width: 354px" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <a id="btnSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveData(false)">保存</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =true },
              new FunctionModule(){Name = "Edit",IsEnable =true },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =true },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =false },
              new FunctionModule(){Name = "AllAdd",IsEnable =false },
              
              
            }
        }
    }
})

</body>

